package com.kye.express.business.more;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.jakewharton.rxbinding2.view.RxView;
import com.kye.base.DebounceObservableTransformer;
import com.kye.express.R;
import com.kye.express.business.base.BaseToolbarActivity;
import com.kye.express.business.invoice_online.InvoiceOnlineActivity;
import com.kye.express.business.popularity.PopularityActivity;
import com.kye.express.databinding.ActivityMoreBinding;

import io.reactivex.functions.Consumer;

/**
 * 更多功能 Activity
 * <p>
 * Created by SkyYu on 2018/2/9
 */
public class MoreFunctionsActivity extends BaseToolbarActivity {

    private ActivityMoreBinding mBinding;

    public static void startActivity(Context context) {
        context.startActivity(new Intent(context, MoreFunctionsActivity.class));
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initViews();
        initEvent();
    }

    private void initViews() {
        initDataBinding();
        initToolbar();
    }

    private void initDataBinding() {
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_more);
    }

    private void initToolbar() {
        setUpToolbar(mBinding.toolbarMore);
        setTitle(getString(R.string.more_title));
    }

    private void initEvent() {
        RxView.clicks(mBinding.linearlayoutInvoice)
                .compose(new DebounceObservableTransformer<>())
                .compose(this.bindToLifecycleDestroy())
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {
                        InvoiceOnlineActivity.startActivity(MoreFunctionsActivity.this);
                    }
                });
        RxView.clicks(mBinding.linearlayoutPopularity)
                .compose(new DebounceObservableTransformer<>())
                .compose(this.bindToLifecycleDestroy())
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {
                        PopularityActivity.startActivity(MoreFunctionsActivity.this);
                    }
                });
        RxView.clicks(mBinding.linearlayoutShakereddevelope)
                .compose(new DebounceObservableTransformer<>())
                .compose(this.bindToLifecycleDestroy())
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {
                        // todo
                    }
                });
    }
}